$(document).ready(function() {
	var isRoomListDown = false;
	var isWallListDown = false;
	
	$('#st-room').click(function(event) {
		if(isWallListDown) {
			return false;
		}
		
		event.preventDefault();
		
		if(isRoomListDown) {		
			$('#st-roomlist-bg').animate({top:'-565px'});
			$('#st-roomlist').animate({top:'-565px'});
			isRoomListDown = false;
			$(this).css('background-image', "url('images/dropdown.png')");
		} else {
			$('#st-roomlist-bg').animate({top:'35px'});
			$('#st-roomlist').animate({top:'35px'});
			isRoomListDown = true;
			$(this).css('background-image', "url('images/dropup.png')");
		}
	});
	
	$('#st-wall').click(function(event) {
		if(isRoomListDown || $('#simulator-bg').css('background-image').indexOf("1.3.jpg") < 0) {
			return false;
		}
		
		event.preventDefault();
		
		if(isWallListDown) {		
			$('#st-roomlist-bg').animate({top:'-565px'});
			$('#st-walllist').animate({top:'-565px'});
			isWallListDown = false;
			$(this).css('background-image', "url('images/dropdown.png')");
		} else {
			$('#st-roomlist-bg').animate({top:'35px'});
			$('#st-walllist').animate({top:'35px'});
			isWallListDown = true;
			$(this).css('background-image', "url('images/dropup.png')");
		}
	});
	
	$('.st-room-instant').click(function(event) {
		event.preventDefault();
		
		$('#simulator-wall').css('display', 'none');
		$('#simulator-bg').css('background-image', "url('" + $(this).find('img').attr('src') + "')");
		$('#st-roomlist-bg').animate({top:'-565px'});
		$('#st-roomlist').animate({top:'-565px'});
		isRoomListDown = false;
		$('#st-room').css('background-image', "url('images/dropdown.png')");
	});
	
	$('.st-wall-instant').click(function(event) {
		event.preventDefault();		
		
		$img_url = $(this).find('img').attr('alt');
		$('#st-roomlist-bg').animate({top:'-565px'});
		$('#st-walllist').animate({top:'-565px'}, function(){
			$('#simulator-wall').fadeOut('normal', function(){				
				$('#simulator-wall').css('background-image', "url('images/rooms/1.3_" + $img_url + ".png')");
				$('#simulator-wall').fadeIn('normal');				
			});			
		});
		isWallListDown = false;
		$('#st-wall').css('background-image', "url('images/dropdown.png')");
	});
	
	$('.st-room-instant').mouseenter(function(event) {
		$(this).find('.st-room-des').stop().animate({bottom:'0px'});
	});
	$('.st-room-instant').mouseleave(function(event) {
		$(this).find('.st-room-des').stop().animate({bottom:'-25px'});
	});
	
	$('.st-wall-instant').mouseenter(function(event) {
		$(this).find('.st-wall-des').stop().animate({bottom:'0px'});
	});
	$('.st-wall-instant').mouseleave(function(event) {
		$(this).find('.st-wall-des').stop().animate({bottom:'-25px'});
	});
});